//
//  XJ_NavViewController.m
//  XunJieProject
//
//  Created by 薛子 on 2018/6/7.
//  Copyright © 2018年 Soowin. All rights reserved.
//

#import "XJ_NavViewController.h"

@interface XJ_NavViewController ()

@end

@implementation XJ_NavViewController
-(NSMutableArray*)daysArr{
    
    if (!_daysArr) {
        _daysArr =[[NSMutableArray alloc]init];
        NSUInteger days =[self getCurrentDaysNum];
        for (int i=1; i<=days; i++) {
            [_daysArr addObject:[NSString stringWithFormat:@"%d",i]];
        }
    }
    return _daysArr;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor =RGBCOLOR(239, 239, 238);
    
    //1、隐藏自带的导航 底部view
    self.navigationController.navigationBar.hidden=YES;
    
    if (@available(iOS 11.0, *)) {
        
        [[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
    }
 
    //2、自定义导航栏底部   颜色值 243 92 20
    self.nav_btmView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SafeAreaTopHeight)];
    self.nav_btmView.backgroundColor =Color_ZhuSeDiao;
    [self.view addSubview:self.nav_btmView];
    
    //2.添加状态栏
    self.statusBarView = [[UIView alloc]initWithFrame:CGRectMake(0, 0,SCREEN_WIDTH, kStatusBarHeight)];
    self.statusBarView.backgroundColor = [UIColor blackColor];
    [self.view addSubview:self.statusBarView];
    
    
    // 3、 创建标题
    self.nav_titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, SafeAreaTopHeight-44, SCREEN_WIDTH, 44)];
    self.nav_titleLabel.textAlignment = NSTextAlignmentCenter;
    self.nav_titleLabel.textColor = WhiteColor;
    self.nav_titleLabel.font =[UIFont boldSystemFontOfSize:18.0f];
    self.nav_titleLabel.font =[UIFont fontWithName:Font_Name size:18.0];
    [self.nav_btmView addSubview:self.nav_titleLabel];
    
    //4.创建返回按钮image
    self.nav_backImg =[[UIImageView alloc]initWithFrame:CGRectMake(14, kStatusBarHeight+(44-20)/2, 12, 20)];
    self.nav_backImg.backgroundColor =ClearColor;
    self.nav_backImg.clipsToBounds =YES;
    self.nav_backImg.contentMode =UIViewContentModeScaleAspectFit;
    self.nav_backImg.image  = [UIImage imageNamed:@"img_go_back"];
    [self.nav_btmView addSubview:self.nav_backImg];
    
    // 5. 创建返回按钮
    self.nav_backButton =[[UIButton alloc]initWithFrame:CGRectMake(0, SafeAreaTopHeight-44, 50, 44)];
    self.nav_backButton.titleLabel.font =[UIFont systemFontOfSize:14.0];
    self.nav_backButton.titleLabel.textAlignment =NSTextAlignmentLeft;
    [self.nav_backButton addTarget:self action:@selector(backButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [self.nav_backButton setImage:[UIImage imageNamed:@"ret_btn_bg"] forState:UIControlStateNormal];
    [self.nav_btmView addSubview:self.nav_backButton];
    
    
    //4.创建右侧按钮image
    self.nav_rightImg =[[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-40, kStatusBarHeight+(44-25)/2, 25, 25)];
    self.nav_rightImg.backgroundColor =ClearColor;
    self.nav_rightImg.clipsToBounds =YES;
    self.nav_rightImg.contentMode =UIViewContentModeScaleAspectFit;
    [self.nav_btmView addSubview:self.nav_rightImg];
    self.nav_rightImg.hidden =YES;
    
    self.noreadImage = [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.nav_rightImg.frame), kStatusBarHeight+(44-25)/2, 10, 10)];
    self.noreadImage.layer.cornerRadius = 5;
    self.noreadImage.backgroundColor=[UIColor whiteColor];
    self.noreadImage.hidden = YES;
    [self.nav_btmView addSubview:self.noreadImage];
    
    
    // 4. 创建导航栏右侧第一按钮
    self.nav_rightButton = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-70, SafeAreaTopHeight-44, 60, 44)];
    self.nav_rightButton.backgroundColor =[UIColor clearColor];
    [self.nav_rightButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.nav_rightButton.titleLabel.font =[UIFont systemFontOfSize:14.0];
    self.nav_rightButton.titleLabel.textAlignment =NSTextAlignmentRight;
    [self.nav_rightButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
    self.nav_rightButton.hidden= YES;
    [self.nav_btmView addSubview:self.nav_rightButton];
    
    
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    }
    
    self.automaticallyAdjustsScrollViewInsets =NO;
    
    [self creatMainUI];
    
}
-(void)creatMainUI{
    
}
- (void)hideMySelfNavgation {
    self.nav_btmView.hidden = YES;
}
- (void)backButtonClick {
    [self.navigationController popViewControllerAnimated:YES];
}


-(NSInteger)getCurrentDaysNum{
    
    NSDate *date =[NSDate date];//简书 FlyElephant
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy"];
    NSInteger currentYear=[[formatter stringFromDate:date] integerValue];
    [formatter setDateFormat:@"MM"];
    NSInteger currentMonth=[[formatter stringFromDate:date]integerValue];
    [formatter setDateFormat:@"dd"];
    //    NSInteger currentDay=[[formatter stringFromDate:date] integerValue];
    
    NSString *days=[self getDayNumber:currentYear month:currentMonth];
    NSInteger daysNum =[days integerValue];
    return daysNum;
}

- (NSString *)getDayNumber:(NSInteger)year month:(NSInteger)month{
    NSArray *days = @[@"31", @"28", @"31", @"30", @"31", @"30", @"31", @"31", @"30", @"31", @"30", @"31"];
    if (2 == month && 0 == (year % 4) && (0 != (year % 100) || 0 == (year % 400))) {
        return @"29";
    }
    return days[month - 1];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
